package com.zl.tby.screen.vo.mountains;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 巡护统计
 * @author changpeng
 * @version 1.0
 * @since 2024/10/26 19:08
 */
@Data
public class TbyPatrolStatisticBean {
    private Long userId;
    /**巡护时长 */
    private BigDecimal duration;
    /**巡护距离 */
    private BigDecimal distance;
    /**巡护次数 */
    private Long time;
    /**巡护人数 */
    private Long personCount;

    public static TbyPatrolStatisticBean init() {
        TbyPatrolStatisticBean bean = new TbyPatrolStatisticBean();
        bean.setTime(0L);
        bean.setPersonCount(0L);
        bean.setDistance(BigDecimal.ZERO);
        bean.setDuration(BigDecimal.ZERO);
        return bean;
    }

    /**距离和时长，四舍五入两位小数*/
    public void convert() {
        if (this.duration != null) {
            this.duration = this.duration.setScale(2, RoundingMode.HALF_UP);
        } else {
            this.duration = BigDecimal.ZERO;
        }
        if (this.distance != null) {
            this.distance = this.distance.setScale(2, RoundingMode.HALF_UP);
        } else {
            this.distance = BigDecimal.ZERO;
        }
    }
}
